﻿
namespace EasyNet.Solr.Impl
{
    using System.Text;

    using Commons;

    /// <summary>
    /// 文本格式数据编解码器
    /// </summary>
    public class TextCodecFactory : ICodecFactory
    {
        /// <summary>
        /// 字符编码
        /// </summary>
        private readonly Encoding encoding = Encoding.UTF8;

        /// <summary>
        /// 默认构造函数
        /// </summary>
        public TextCodecFactory()
        {

        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="encoding">字符编码</param>
        public TextCodecFactory(Encoding encoding)
        {
            this.encoding = encoding;
        }

        /// <summary>
        /// 创建编解码器
        /// </summary>
        /// <returns>文本格式数据编解码器</returns>
        public ICodec Create()
        {
            return new TextCodec() { Encoding = encoding };
        }
    }
}
